<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!--返回错误信息-->
<?php echo validation_errors(); ?>
<!DOCTYPE html>
<html lang="en">

<head>
    <?php
    $title = [
        'title' => '招投标管理',
    ];
    $this->load->view('/admin/common/header', $title);
    ?>
</head>

<body data-type="widgets">
<?php
//如果需要用证书加密，使用phpseclib包
// set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
// require("File/X509.php");
// require("Crypt/RSA.php");

//如果不用证书加密，使用php_rsa.php函数
// require_once("./php_rsa.php");

//测试商户的key! 请修改。
$md5key = "1234567890";

$merchantId=$_POST["merchantId"];
$version=$_POST['version'];
$language=$_POST['language'];
$signType=$_POST['signType'];
$payType=$_POST['payType'];
$issuerId=$_POST['issuerId'];
$paymentOrderId=$_POST['paymentOrderId'];
$orderNo=$_POST['orderNo'];
$orderDatetime=$_POST['orderDatetime'];
$orderAmount=$_POST['orderAmount'];
$payDatetime=$_POST['payDatetime'];
$payAmount=$_POST['payAmount'];
$ext1=$_POST['ext1'];
$ext2=$_POST['ext2'];
$payResult=$_POST['payResult'];
$errorCode=$_POST['errorCode'];
$returnDatetime=$_POST['returnDatetime'];
$signMsg=$_POST["signMsg"];

//var_dump($_POST);


$bufSignSrc="";
if($merchantId != "")
    $bufSignSrc=$bufSignSrc."merchantId=".$merchantId."&";
if($version != "")
    $bufSignSrc=$bufSignSrc."version=".$version."&";
if($language != "")
    $bufSignSrc=$bufSignSrc."language=".$language."&";
if($signType != "")
    $bufSignSrc=$bufSignSrc."signType=".$signType."&";
if($payType != "")
    $bufSignSrc=$bufSignSrc."payType=".$payType."&";
if($issuerId != "")
    $bufSignSrc=$bufSignSrc."issuerId=".$issuerId."&";
if($paymentOrderId != "")
    $bufSignSrc=$bufSignSrc."paymentOrderId=".$paymentOrderId."&";
if($orderNo != "")
    $bufSignSrc=$bufSignSrc."orderNo=".$orderNo."&";
if($orderDatetime != "")
    $bufSignSrc=$bufSignSrc."orderDatetime=".$orderDatetime."&";
if($orderAmount != "")
    $bufSignSrc=$bufSignSrc."orderAmount=".$orderAmount."&";
if($payDatetime != "")
    $bufSignSrc=$bufSignSrc."payDatetime=".$payDatetime."&";
if($payAmount != "")
    $bufSignSrc=$bufSignSrc."payAmount=".$payAmount."&";
if($ext1 != "")
    $bufSignSrc=$bufSignSrc."ext1=".$ext1."&";
if($ext2 != "")
    $bufSignSrc=$bufSignSrc."ext2=".$ext2."&";
if($payResult != "")
    $bufSignSrc=$bufSignSrc."payResult=".$payResult."&";
if($errorCode != "")
    $bufSignSrc=$bufSignSrc."errorCode=".$errorCode."&";
if($returnDatetime != "")
    $bufSignSrc=$bufSignSrc."returnDatetime=".$returnDatetime;





//signType 0 验签

if($payResult == 1)
{
    $pay_Result_0 = "订单支付成功！";


}
else
{
    $pay_Result_0 = "订单支付失败！";
}

if($signMsg == strtoupper(md5($bufSignSrc."&key=".$md5key)))
{
    $verify_Result_0 = "报文验签成功!";
}
else
{
    $verify_Result_0 = "报文验签失败!";
}



?>
	<script src="/assets/js/theme.js"></script>
	<div class="am-g tpl-g">

	    <!--    头部   侧边菜单-->
	    <?php $this->load->view('/admin/common/bodyLeft'); ?>
    <script type="text/javascript">
    	$(".js-sidebar-nav>li:nth-child(12)>ul").show(80);
    	$(".js-sidebar-nav>li:nth-child(12)>a>span").addClass("sidebar-nav-sub-ico-rotate");
    	$(".js-sidebar-nav>li:nth-child(12)>ul>li:nth-child(2)>a").addClass("active");
    </script>
	    <!-- 内容区域 -->
	    
	</div>
	<div class="tpl-content-wrapper pay-result">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <div class="widget-head am-cf">
                            <div class="widget-title  am-cf">
                                <ol class="am-breadcrumb am-breadcrumb-slash">
                                    <li><a href="/admin/bidding/index?page=1">招投标管理</a></li>
                                    <li class="am-active"><a href="/admin/bidding/waitingList?page=1">供应商待办</a></li>
                                    <li class="am-active">保证金支付结果页</li>
                                </ol>
                            </div>
                        </div>
                        <div class="pay-result-content">
		                    <h1 class="pay-result"><?=$pay_Result_0?></h1>
                            <hr/>
                            <div>商户号：<?=$merchantId ?> </div>
                            <div>商户订单号：<?=$orderNo ?> </div>
                            <div>商户订单金额：<?=$orderAmount ?></div>
                            <div>商户订单时间：<?=$orderDatetime ?> </div>
                            <div>网关支付金额：<?=$payAmount ?></div>
                            <div>网关支付时间：<?=$payDatetime ?></div>

		                    <p><span class="span-left">招投标编号：</span><span class="span-right">215115135</span></p>
		                    <p><span class="span-left">商户订单号：</span><span class="span-right" id="orderNo"><?=$orderNo ?></span></p>
		                    <p><span class="span-left">商户订单金额：</span><span  class="span-right"><?=$orderAmount ?></span></p>

                            <?php
                                if($pay_Result_0 == '订单支付成功！'){
                                    echo '
                                    <p><span class="span-left">提<span class="hidden">试试撒</span>示：</span><span  class="span-right">保证金支付成功，待财务确认到款后，可以进行标书文件下载。</span></p>
		                    <div class="btn-box">
			                    <a href="/admin/bidding/waitingList?page=1"><button type="button" class="am-btn am-btn-primary">返回列表页</button></a>
		                    </div>
		                    ';
                                }else{
                                      echo '<p><span class="span-left">提<span class="hidden">试试撒</span>示：</span><span  class="span-right">支付失败</span></p>
		                    <div class="btn-box">
			                    <button type="button" class="am-btn am-btn-primary ">重新支付</button>
		                    </div>';
                                }
                            ?>

	                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

	<script>
	    function back() {
	        window.history.back();
	    }
        $(function(){
            var payResult = $(".pay-result-content").find(".pay-result").text();
            var status;  //支付是否成功状态；成功为2   失败4
            var orderNo = $("#orderNo").text();
            if(payResult == "订单支付成功！"){
                status = 2;
            }else{
                status = 4;
            }
            console.log(payResult+"+"+status);
            console.log(orderNo);
            $.ajax({
                url:"/admin/bidding/editWaitStatus",
                data:{
                    orderNo: orderNo ,
                    status: status
                },
                type:"post",
                success:function(){

                }
            });
        })




	</script>

	<script src="/assets/js/amazeui.min.js"></script>
	<script src="/assets/js/amazeui.datatables.min.js"></script>
	<script src="/assets/js/dataTables.responsive.min.js"></script>
	<script src="/assets/js/app.js"></script>

</body>

</html>